package org.kumas.sgrpc.remoting;

import org.kumas.sgrpc.common.extension.ExtensionLoader;

public class Dispatcher$Adaptive implements org.kumas.sgrpc.remoting.Dispatcher {

    public org.kumas.sgrpc.remoting.ChannelHandler dispatch(
        org.kumas.sgrpc.remoting.ChannelHandler arg0, org.kumas.sgrpc.common.URL arg1) {
        if (arg1 == null) {
            throw new IllegalArgumentException("url == null");
        }
        org.kumas.sgrpc.common.URL url = arg1;
        String extName = url.getParameter("dispatcher", "AllDispatcher");
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (org.kumas.sgrpc.remoting.Dispatcher) name from url ("
                    + url.toString() + ") use keys([dispatcher])");
        }
        org.kumas.sgrpc.remoting.Dispatcher extension = (org.kumas.sgrpc.remoting.Dispatcher) ExtensionLoader
            .getExtensionLoader(org.kumas.sgrpc.remoting.Dispatcher.class).getExtension(extName);
        return extension.dispatch(arg0, arg1);
    }
}